Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Make cog_modules_add_directory() honor COG_MODULEDIR #659

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

aperezdc
Copy link
Member

Move handling of the COG_MODULEDIR environment variable into the cog_modules_add_directory() function, fix the bug that skipped using the environment variable when cog_init() is not used, and improve robustness:

  • The path passed is checked to be a valid directory location.
  • The environment variable is checked only once for the whole execution of the process, the first time the function is called with a NULL argument.
  • The path in the environment variable is checked for validity as well. A warning is produced for invalid locations.
  • If either the environment variable or the compiled-in default path are used, it is considered that the “default” path was set, and will not be set again to avoid re-scanning directories unnecessarily.

While at it, sprinkle comments on the code to explain the logic.


This depends on changes from #655

@aperezdc aperezdc added the enhancement New feature or request label Nov 14, 2023
@aperezdc aperezdc self-assigned this Nov 14, 2023
@aperezdc aperezdc enabled auto-merge (rebase) November 14, 2023 10:49
Copy link
Member

@psaavedra psaavedra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#659 makes this even more robust and allows to dont need to use the cog_init().

Ref: #655 (comment)

Move handling of the COG_MODULEDIR environment variable into the
cog_modules_add_directory() function, fix the bug that skipped using
the environment variable when cog_init() is not used, and improve
robustness:

- The path passed is checked to be a valid directory location.
- The environment variable is checked only once for the whole
  execution of the process, the first time the function is called
  with a NULL argument.
- The path in the environment variable is checked for validity as
  well. A warning is produced for invalid locations.
- If either the environment variable or the compiled-in default
  path are used, it is considered that the "default" path was set,
  and will not be set again to avoid re-scanning directories
  unnecessarily.

While at it, sprinkle comments on the code to explain the logic.
@aperezdc aperezdc merged commit 9c342d3 into master Nov 16, 2023
4 checks passed
@aperezdc aperezdc deleted the aperezdc/loader-robusteness branch November 16, 2023 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants